var a = require("../../../../@babel/runtime/helpers/defineProperty"), t = require("../../../../mycomponent/yz_pay/yz_pay"), e = require("../../../../utils/themeSkin/skinBehavior"), n = getApp();

Page({
    behaviors: [ t, e ],
    data: {
        language: "",
        credit2: 0,
        buttons: [],
        typename: "",
        recharge: "",
        ordersn: "",
        money: "",
        activatDes: {},
        pay_type: "",
        balanceLang: "余额"
    },
    onLoad: function(a) {
        console.log(a.balance), a.balance && this.setData({
            money: a.balance
        }), this.getData();
        try {
            var t = wx.getStorageSync("yz_basic_info");
            (t = t.balance || "余额") && this.setData({
                balanceLang: t
            });
        } catch (a) {
            console.log(a);
        }
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShareAppMessage: function() {},
    getData: function() {
        var t = this, e = n.getNetAddresss("finance.balance.balance");
        n._getNetWork({
            url: e,
            success: function(e) {
                var n = e.data;
                if (1 == n.result) {
                    t.setData({
                        credit2: n.data.credit2,
                        buttons: n.data.buttons,
                        typename: n.data.typename,
                        recharge: n.data.recharge,
                        activatDes: n.data.remark
                    });
                    for (var o = 0; o < t.data.buttons.length; o++) t.data.buttons[o] && (t.setData(a({}, "buttons[" + o + "].btclass", t.btnclass(t.data.buttons[o].value))), 
                    console.log(t.data.buttons));
                    wx.setNavigationBarColor({
                        frontColor: "#ffffff",
                        backgroundColor: t.data.themeBaseColor,
                        animation: {
                            duration: 400,
                            timingFunc: "easeIn"
                        }
                    });
                } else wx.showToast({
                    icon: "none",
                    title: n.msg,
                    duration: 1500
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    moneyinp: function(a) {
        var t = a.detail.value;
        this.setData({
            money: t
        });
    },
    confirm: function(a) {
        var t = this, e = a.currentTarget.dataset.val;
        if (this.setData({
            money: parseFloat(this.data.money),
            pay_type: e
        }), this.data.money <= 0) wx.showToast({
            icon: "none",
            title: "金额不可低于0",
            duration: 1500
        }); else {
            var o = n.getNetAddresss("finance.balance.recharge");
            o += "&client_type=2", o += "&app_type=wechat", o += "&pay_type=" + this.data.pay_type, 
            o += "&recharge_money=" + this.data.money, n._getNetWork({
                url: o,
                success: function(a) {
                    var o = a.data;
                    if (1 == o.result) {
                        if ("88" == t.data.pay_type) return void wx.showModal({
                            title: "",
                            showCancel: !1,
                            content: "充值成功",
                            success: function(a) {
                                wx.navigateBack({
                                    delta: 1
                                });
                            }
                        });
                        if (n._isTextEmpty(o.data.ordersn)) return void wx.showToast({
                            icon: "none",
                            title: "参数错误",
                            duration: 1500
                        });
                        t.setData({
                            ordersn: o.data.ordersn
                        }), t.rechargePay(e, o, o.data.ordersn, "balance");
                    } else wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    }), 102 == e && 1 == o.data.eplus_bind_mobile && (wx.navigateTo({
                        url: "/packageF/others/wisdom/wisdomBind/wisdomBind?option=phone&to=pay"
                    }), n.tips(a.msg));
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    }
});